package com.project.seckill;

import com.project.seckill.constant.CacheConstant;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author shenguangyang
 * @date 2022-09-02 20:48
 */
@Component
public class AppRunner implements ApplicationRunner {
    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public void run(ApplicationArguments args) {
        String goodsKey = String.format(CacheConstant.GOODS_STOCK_KEY, "1");
        redisTemplate.opsForHash().put(goodsKey, CacheConstant.GOODS_STOCK_HASH_KEY, 200000);
    }
}
